﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HRM.BLL;
using HRM.DAL.DAO;
using HRM.ReportGateway;

namespace HRM.ReportAll
{
    public partial class rptPayRoll : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                LoadProject();
            }
        }
        private void LoadProject()
        {
            List<Project> projects = new List<Project>();
            ProjectManager manager = new ProjectManager();
            projects = manager.GetAllProjects();
            ddlEmpProject.DataTextField = "ProjectName";
            ddlEmpProject.DataValueField = "Id";
            ddlEmpProject.DataSource = projects;
            ddlEmpProject.DataBind();
            ddlEmpProject.Items.Insert(0, "---Choose Any---");

            selectProject.DataTextField = "ProjectName";
            selectProject.DataValueField = "Id";
            selectProject.DataSource = projects;
            selectProject.DataBind();
            selectProject.Items.Insert(0, "---Choose Any---");

            selectProject3.DataTextField = "ProjectName";
            selectProject3.DataValueField = "Id";
            selectProject3.DataSource = projects;
            selectProject3.DataBind();
            selectProject3.Items.Insert(0, "---Choose Any---");

        }
        protected void ShowEmpPayrollReport(object o,EventArgs e)
        {
            ReportDataGateway rptGateway =new ReportDataGateway();
            DataTable  ds=new DataTable();
            int projId = Convert.ToInt32(ddlEmpProject.Value);
            string month = selectMonth.Value;
            string year = selectYear.Value;
            ds = rptGateway.GetPayReportByProjectAndMonth(projId, month, year);
            PayRollReportByProjectAndYearAndMonth report = new PayRollReportByProjectAndYearAndMonth();
            report.SetDataSource(ds);
            CrtViewer.ReportSource = report;

        }

        protected void ShowEmpPayrollReportByProjectAndYear(object o, EventArgs e)
        {
            ReportDataGateway rptGateway = new ReportDataGateway();
            DataTable ds = new DataTable();
            int projId = Convert.ToInt32(selectProject.Value);
            string year = selectYearforReport2.Value;
            ds = rptGateway.GetPayReportByProjectAndYear(projId,year);
            PayrollReportByProjectAndYear report = new PayrollReportByProjectAndYear();
            report.SetDataSource(ds);
            CrtViewer.ReportSource = report;

        }

        protected void ShowEmpPayrollReportByProject(object o, EventArgs e)
        {
            ReportDataGateway rptGateway = new ReportDataGateway();
            DataTable ds = new DataTable();
            int projId = Convert.ToInt32(selectProject3.Value);
            ds = rptGateway.GetPayReportByProject(projId);
            PayRollReportByProject report = new PayRollReportByProject();
            report.SetDataSource(ds);
            CrtViewer.ReportSource = report;

        }

        protected void ShowYearlyExpenduture(object o, EventArgs e)
        {
            ReportDataGateway rptGateway = new ReportDataGateway();
            DataTable ds = new DataTable();
            string year = selectYearforReport4.Value;
            ds = rptGateway.GetYearlyExpenduture(year);
            ReportYearlyExpenduture report = new ReportYearlyExpenduture();
            report.SetDataSource(ds);
            CrtViewer.ReportSource = report;

        }

        protected void ShowAllPayReportOfTheCompany(object o, EventArgs e)
        {
            ReportDataGateway rptGateway = new ReportDataGateway();
            DataTable ds = new DataTable();
            ds = rptGateway.GetAllPayrollOfTheCompany();
            ReportAllPayrollofTheCompany report = new ReportAllPayrollofTheCompany();
            report.SetDataSource(ds);
            CrtViewer.ReportSource = report;

        }
    }
}